<?php
class yellowpage extends MX_Controller {

	var $data		= null;
	var $module		= null;
	var $controller	= null;
	var $url		= null;
	var $table		= "";
	var $template = "_yellowpage";
		
	/*@ Set Constructor*/
	public function __construct()
	{
		parent::__construct();
		ini_set('error_reporting', E_ALL);
		$this->load->model('yellowpage_model');
		$this->data['module']			=	$this->module = $this->uri->segment(1);
		$this->data['URLPATH_IMAGES']	=	URLPATH_MOD.'modules/'.$this->module."/asset/images/";
		$this->data['URLPATH_JS']		=	URLPATH_MOD.'modules/'.$this->module."/asset/js/";
		$this->data['URLPATH_CSS']		=	URLPATH_MOD.'modules/'.$this->module."/asset/css/";
		$this->data['BASE_URL']	= URLPATH_MOD.'index.php/'.$this->module.'/'; 
	}
		
	/*@ Load Default */
	public function index()
	{
		$this->data['content'] = $this->load->view('index_view',$this->data, true);
		$this->data['header'] = array('title' => 'yellopage');
		$this->data['template'] =  $this->template;
		$this->load->view("{$this->template}/page", $this->data);
	}
	
	public function search(){

 		$output_arr = $this->yellowpage_model->search();	
				//print_r($output_arr);
				$output="<table>";
				foreach($output_arr as $rd){
				$output.="<tr onclick=\"sel('{$rd['EM_CODE']}');\" onmouseover=\"showEmPic('{$rd['EM_CODE']}');\">
				<td><img src='http://www.lpnis.com/hrportal/application/employees/Picture/{$rd['EM_PIC']}' width='80'></td>
				<td>{$rd['EM_TNAME']}</td>
				<td>{$rd['EM_TSURNAME']}</td>
				<td>{$rd['EA_PHONE']}</td>
				</tr>";
				}
				
				$output.="</table>";
				echo $output;	/*	 */
		}
		public function download_vcard(){
				$this->load->library('vcard');
				$vc = new vcard();
				$_id = $this->uri->segment(3);
				$rd = $this->yellowpage_model->get_em($_id);
			$vc->data['display_name'] = $rd->EM_ENAME.'_'.$rd->EM_ESURNAME;
				$vc->data['first_name'] =$rd->EM_NICKNAME;
				$vc->data['last_name'] = $rd->EORG_04;
				$vc->data['nickname'] =$rd->EM_NICKNAME;
				$vc->data['company'] = "LPN";
				$vc->data['department'] = $rd->EORG_04;
				$vc->data['title'] = $rd->EORG_01;
				$vc->data['cell_tel'] = $rd->EA_PHONE;
				$vc->data['photo'] = $this->get_photo($rd->EM_PIC);
				$vc->data['fax_tel'] = "";
				$vc->data['email1'] = $rd->EM_MAIL;
				$tmp=split("/",$rd->EM_BIRTHDATE2);
				$y=intval($tmp[2])-543;
				$bday = $y.'-'.$tmp[1].'-'.$tmp[0];
				$vc->data['birthday'] = $bday;
				$vc->data['timezone'] = "+07:00";
				$vc->download(); 
		}
		
		private function get_photo($em_pic){
				
					$images = realpath(APPPATH."../../");
					$images ="http://www.lpnis.com/hrportal/application/employees/Picture/{$em_pic}";
					$new_images = "http://www.lpnis.com/hrportal/tmp/_small_{$em_pic}";
					return  base64_encode(file_get_contents($images));
		}
		
	}


/* End of file members.php */
/* Location: ./modules/members/controllers/members.php */